﻿namespace ServerBase.Config;

/// <summary>
/// 策划设置配置
/// </summary>
public static partial class Conf
{
    /// <summary>
    /// 配置后续处理
    /// </summary>
    /// <returns></returns>
    public static bool InitConfSettingsExt()
    {
        CfgGlobal = ConfGlobal.ToDictionary
            (it => (EGlobalId)it.Value.GlobalId, it => new GlobalConfigExt(it.Value));

        ConfSurnameExt.Clear();
        ConfMalenameExt.Clear();
        ConfFemalenameExt.Clear();
        ConfBadwordsExt.Clear();
        switch (SvInfo.Language)
        {
            case ELanguage.英语:
                foreach (var item in ConfNameSur.Values) { ConfSurnameExt.Add(item.LangEn); }
                foreach (var item in ConfNameMale.Values) { ConfMalenameExt.Add(item.LangEn); }
                foreach (var item in ConfNameFemale.Values) { ConfFemalenameExt.Add(item.LangEn); }
                //foreach (var item in ConfBadwords.Values) { ConfBadwordsExt.Add(item.LangEn); }
                break;
            default:
                foreach (var item in ConfNameSur.Values) { ConfSurnameExt.Add(item.LangChs); }
                foreach (var item in ConfNameMale.Values) { ConfMalenameExt.Add(item.LangChs); }
                foreach (var item in ConfNameFemale.Values) { ConfFemalenameExt.Add(item.LangChs); }
                foreach (var item in ConfNameBad.Values) { ConfBadwordsExt.Add(item.LangChs); }
                break;
        }

        ConfRoomExt = ConfRoom.ToDictionary(it => it.Value.Id, it => new ConfigRoomExt(it.Value));
        ConfCityRoom.Clear();
        foreach (var item in ConfRoom.Values)
        {
            ConfCityRoom.TryAdd(item.CityUid, item.Id);
        }

        ConfItemExt = ConfItem.ToDictionary(it => it.Value.Id, it => new ConfigItemExt(it.Value));

        ConfNpcExt = ConfNpc.ToDictionary(it => it.Value.Id, it => new ConfigNpcExt(it.Value));

        ConfListUsage = Util.GetValues<EUsageType>();

        ConfWeaponTypeExt = ConfWeaponType.ToDictionary
           (it => (EWeaponType)(it.Value.WeaponType), it => new ConfigWeaponTypeExt(it.Value));

        ConfRaceExt = ConfRace.ToDictionary
           (it => (ERace)(it.Value.Race), it => new ConfigRaceExt(it.Value));

        ConfSkillActionNormal.Clear();
        foreach (var item in ConfCbtAction.Values)
        {
            if (item.ActionType != "skill")
            {
                continue;
            }
            if ((ECbtActionType)item.CbtActionType == ECbtActionType.normal)
            {
                ConfSkillActionNormal.TryAdd(item.SkillId, item);
            }
        }

        ConfDescGuardExt = ConfDescGuard.Values.Select(it=>it.Desc).ToList();
        ConfDescWinnerExt = ConfDescWinner.Values.Select(it=>it.Desc).ToList();

        ConfSkillDodgeExt.Clear();
        foreach (var item in ConfSkillDodge.Values)
        {
            ConfSkillDodgeExt.TryAdd(item.SkillId, item.Id);
        }

        ConfSkillParryExt.Clear();
        foreach (var item in ConfSkillParry.Values)
        {
            ConfSkillParryExt.TryAdd(item.SkillId, item.Desc);
        }

        ConfCbtDamageExt.Clear();
        foreach (var item in ConfCbtDamage.Values)
        {
            foreach (var item2 in item.DamageType)
            {
                ConfCbtDamageExt.TryAdd(item2, item);
            }
        }

        return true;
    }

}

